"""nsproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path
from django.urls import re_path
from gongyequ.views import auth
from gongyequ.views import user_admin
from gongyequ.views import upload_file
from gongyequ.views import survey_api

urlpatterns = [
    path('industrialapi/auth/userinfo', auth.api_userinfo, name='api-userinfo'),
    path('industrialapi/auth/logout', auth.api_logout, name='api-logout'),
    path('industrialapi/auth/register', auth.api_register, name='api-register'),
    path('industrialapi/auth/code', auth.image_code, name='api-code'),
    path('industrialapi/auth/login', auth.login, name='api-login'),
    path('industrialapi/auth/reset_password', auth.reset_password, name='api-reset-password'),

    # 短信相关
    path('industrialapi/otp/send_code',auth.send_sms_verify_code),
    path('industrialapi/otp/check_code',auth.check_verify_code),

    # 用户管理相关
    path('industrialapi/admin/users', user_admin.UserView.as_view()),
    path('industrialapi/admin/users/<int:id>', user_admin.UserView.as_view()),
    re_path('industrialapi/admin/users/(?P<id>\d+)/(?P<action>lock|unlock)', user_admin.UserView.as_view()),

    # 文件上传
    path('industrialapi/surveyitem/files',upload_file.survey_files),

    # 项目问卷
    path('industrialapi/surveyitem',survey_api.SurveyView.as_view()),
    path('industrialapi/surveyitem/<int:id>',survey_api.SurveyView.as_view()),
    re_path('industrialapi/surveyitem/(?P<id>\d+)/(?P<action>rejected|assessment|approved|reportdata)',survey_api.SurveyView.as_view()),

    path('industrialapi/surveyitem/history',survey_api.history_assessment)
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)